using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AXBC = Microsoft.Dynamics.BusinessConnectorNet;
using AXMD = Microsoft.Dynamics.Framework.Metadata.Ax;
using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;

namespace DynamicsAXPS
{
    [System.Management.Automation.Cmdlet("Get", "AXLabel")]
    public class Get_AXLabel : System.Management.Automation.PSCmdlet
    {
        [System.Management.Automation.Parameter(Position = 0, Mandatory = true)]
        public string[] LabelIDs = new[] { "@SYS21669" };


        protected override void ProcessRecord()
        {

            var ax = new AXBC.Axapta();
            ax.Logon(null, null, null, null);

            foreach (var labelid in this.LabelIDs)
            {
                string id = labelid;
                if (!labelid.StartsWith("@")) { id = "@" + labelid; }
                var result = ax.CallStaticClassMethod("SysLabel", "labelId2String2", id);
                this.WriteObject(result);
            }
        }
    }
}
